package com.pearl.order.demo.config;

import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

/**
 * @author TD
 * @version 1.0
 * @date 2024/5/27
 */
@Configuration
public class NacosConfig {

    @Bean
    public NacosDiscoveryProperties nacosProperties(Environment environment) {
        NacosDiscoveryProperties discoveryProperties = new NacosDiscoveryProperties();
        Map<String, String> metadata = discoveryProperties.getMetadata();
        metadata.put("startup.time",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        metadata.put("java.version",environment.getProperty("java.version"));
        metadata.put("os.name",environment.getProperty("os.name"));
        metadata.put("pid",environment.getProperty("pid"));
        return discoveryProperties;
    }
}
